package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.SysCarInfo;
import com.ruoyi.system.domain.vo.ApplyCarVo;
import com.ruoyi.system.domain.vo.IndexVo;
import com.ruoyi.system.domain.vo.StatisticsVO;
import com.ruoyi.system.mapper.SysCarInfoMapper;
import com.ruoyi.system.service.ISysCarInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2024-05-29
 */
@Service
public class SysSysCarInfoServiceImpl implements ISysCarInfoService
{
    @Autowired
    private SysCarInfoMapper sysCarInfoMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public SysCarInfo selectCarInfoById(Long id)
    {
        return sysCarInfoMapper.selectCarInfoById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param sysCarInfo 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<SysCarInfo> selectCarInfoList(SysCarInfo sysCarInfo)
    {
        return sysCarInfoMapper.selectCarInfoList(sysCarInfo);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param sysCarInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertCarInfo(SysCarInfo sysCarInfo)
    {
        return sysCarInfoMapper.insertCarInfo(sysCarInfo);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param sysCarInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateCarInfo(SysCarInfo sysCarInfo)
    {
        return sysCarInfoMapper.updateCarInfo(sysCarInfo);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCarInfoByIds(Long[] ids)
    {
        return sysCarInfoMapper.deleteCarInfoByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCarInfoById(Long id)
    {
        return sysCarInfoMapper.deleteCarInfoById(id);
    }

    @Override
    public List<IndexVo> selectIndexList(SysCarInfo sysCarInfo) {
        return sysCarInfoMapper.selectIndexList(sysCarInfo);
    }

    /**
     * 修改
     *
     * @param sysCarInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateCarInfoByHphm(SysCarInfo sysCarInfo)
    {
        return sysCarInfoMapper.updateCarInfoByHphm(sysCarInfo);
    }

    @Override
    public List<SysCarInfo> selectNewData() {
        return sysCarInfoMapper.selectNewData();
    }

    @Override
    public List<SysCarInfo> selectExpData() {
        return sysCarInfoMapper.selectExpData();
    }

    @Override
    public void updateCarInfoBatch(List<Long> ids) {
        sysCarInfoMapper.updateCarInfoBatchStatus(ids);
    }

    @Override
    public List<SysCarInfo> getUpdateList() {
        return sysCarInfoMapper.getUpdateList();
    }

    @Override
    public void updateCarInfoDate(SysCarInfo carInfo) {
         sysCarInfoMapper.updateCarInfoDate(carInfo);
    }

    @Override
    public int status(Long id, Boolean status) {
        SysCarInfo carInfo = sysCarInfoMapper.selectCarInfoById(id);
        carInfo.setStatus(status);
        return sysCarInfoMapper.updateCarInfo(carInfo);
    }

    @Override
    public int jjzzl(Long id, String jjzzl) {
        SysCarInfo carInfo = sysCarInfoMapper.selectCarInfoById(id);
        carInfo.setJjzzl(jjzzl);
        return sysCarInfoMapper.updateCarInfo(carInfo);
    }

    @Override
    public StatisticsVO statistics() {
        StatisticsVO statisticsVO = new StatisticsVO();
        SysCarInfo carInfo = new SysCarInfo();
        carInfo.setStatus(true);
        List<IndexVo> indexVos1 = sysCarInfoMapper.selectIndexList(carInfo);
        statisticsVO.setSum(indexVos1.size());

        carInfo.setJjzzl("02");
        List<IndexVo> indexVos2 = sysCarInfoMapper.selectIndexList(carInfo);
        statisticsVO.setOutsideSum(indexVos2.size());

        carInfo.setJjzzl("01");
        List<IndexVo> indexVos3 = sysCarInfoMapper.selectIndexList(carInfo);
        statisticsVO.setInsideSum(indexVos3.size());
        return statisticsVO;
    }

    @Override
    public List<ApplyCarVo> getTakeEffect(LocalDateTime localDateTime) {
        return sysCarInfoMapper.getTakeEffect(localDateTime);
    }

}
